import time

import allure
from page_object.page_roncoo_pay_login import PageLogin
from page_element.el_Roncoo import *
import logging


# 添加用户+添加产品+添加支付方式+添加支付配置+绑定银行卡+发起结算+
class EditLogin(PageLogin):
    """首页搜索商品后退出登录"""
    # 添加用户
    def page_add_user(self, name, phone, password):
        # 前置条件：已登录
        self.page_login('admin', '123456')
        with allure.step("点击用户管理"):
            self.click(home_pe.user_manage)
        with allure.step("点击用户信息"):
            self.click(home_pe.user_info)
        with allure.step("点击添加用户按钮"):
            self.click(home_pe.add_user_btn)
        with allure.step("输入用户名称"):
            self.send_keys(home_pe.username_inp, name)
        with allure.step("输入手机号"):
            self.send_keys(home_pe.userphone_inp, phone)
        with allure.step("输入登录密码"):
            self.send_keys(home_pe.userpassword_inp, password)
        with allure.step("点击提交"):
            self.click(home_pe.tj_btn)
        time.sleep(3)
        # with allure.step("验证搜索出来的用户名"):
        #     dy = self.text(home_pe.tiao_btn)
        #     assert '45' == dy, '断言失败(验证失败)'
        #     print(f'断言的内容:45 == {dy}')
        #     logging.info(f'断言的内容:45 == {dy}')
        #     logging.info(f'断言的内容:退出系统 == {dy}')
        #     time.sleep(5)

    # 添加产品并设置支付方式
    def page_add_product(self, no, name, money):
        # 前置条件：已登录
        time.sleep(2)
        with allure.step("点击支付管理"):
            self.click(pay_pe.pay_manage)
        with allure.step("点击支付产品信息"):
            self.click(pay_pe.product_info)
        with allure.step("点击添加支付产品"):
            self.click(pay_pe.add_product)
            time.sleep(3)
        with allure.step(f"输入框输入产品编码信息:{no}"):
            self.send_keys(pay_pe.bianma_inp, no)
            time.sleep(3)
        with allure.step(f"输入框输入产品名称信息:{name}"):
            self.send_keys(pay_pe.name_inp, name)
        with allure.step("点击提交按钮"):
            self.click(pay_pe.tj_btn)
        # with allure.step("点击设置支付方式"):
        #     self.click(pay_pe.pay_way)
        #     time.sleep(5)
        # with allure.step("点击设置支付方式"):
        #     self.click(pay_pe.set_pay_way_btn)
        #     time.sleep(2)
        # with allure.step(f"输入框输入支付费率信息:{money}"):
        #     self.send_keys(pay_pe.pay_lv, money)
        # with allure.step("点击提交按钮"):
        #     self.click(pay_pe.pay_way_tj_btn)
        #     time.sleep(2)

    # 添加支付配置
    def page_add_way_set(self, name, namedan):
        # 前置条件：已登录
        time.sleep(3)
        with allure.step("点击用户支付配置"):
            self.click(payconfig_manage.user_pay_config)
        with allure.step("点击添加支付配置"):
            self.click(payconfig_manage.add_payconfig_btn)
            time.sleep(2)
        with allure.step("点击用户编号放大镜"):
            self.click(payconfig_manage.payconfig_user_magnifier_tb)
        with allure.step("选择用户编号和用户名"):
            self.click(payconfig_manage.payconfig_findback_user)
            time.sleep(2)
        with allure.step("点击产品编号放大镜"):
            self.click(payconfig_manage.payconfig_product_magnifier_tb)
        with allure.step("选择产品编号和产品名"):
            self.click(payconfig_manage.payconfig_findback_product)
            time.sleep(2)
        with allure.step(f"输入框输入风险预存期:{name}"):
            self.send_keys(payconfig_manage.fx_inp, name)
        with allure.step(f"输入框输入IP白名单:{namedan}"):
            self.send_keys(payconfig_manage.ip_whitelist_inp, namedan)
        with allure.step("点击提交按钮"):
            self.click(payconfig_manage.payconfig_tj_btn)
            time.sleep(5)

    # 绑定银行卡
    def page_binding_bank(self, q1, q2, q3, q4, q5):
        with allure.step("点击绑定出款银行卡"):
            self.click(payconfig_manage.bind_bank_card)
            time.sleep(2)
        with allure.step(f"输入框输入银行开户名:{q1}"):
            self.send_keys(payconfig_manage.bank_account_name, q1)
        with allure.step(f"输入框输入银行账号:{q2}"):
            self.send_keys(payconfig_manage.bank_number_inp, q2)
        with allure.step(f"输入框输入证件号码:{q3}"):
            self.send_keys(payconfig_manage.id_no_inp, q3)
        with allure.step(f"输入框输入手机号:{q4}"):
            self.send_keys(payconfig_manage.phone_inp, q4)
        with allure.step(f"输入框输入开户行详细地址:{q5}"):
            self.send_keys(payconfig_manage.address_inp, q5)
            time.sleep(2)
        with allure.step("点击提交按钮"):
            self.click(payconfig_manage.tj_btn)
            time.sleep(2)



